function log(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
  console.log('装饰器执行了', target, propertyKey, descriptor)
  const originalGet = descriptor.get;
  const originalSet = descriptor.set;
  if (originalGet) { // 重写 Get 访问器
    descriptor.get = function () {
      const result = originalGet.apply(this);
      console.log('使用了 Get 访问器');
      return result;
    };
  }
  if (originalSet) { // 重写 Set 访问器
    descriptor.set = function (value: any) {
      console.log('使用了 Set 访问器')
      originalSet.apply(this, [value]);
    };
  }
}
class User {
  static _name: string; // 静态属性
  private _name: string; // 实例属性
  constructor(name: string) {
    this._name = name;
  }
  @log
  static get name1() {
    return this._name; // 类的静态访问器中的 this 指向类本身
  }
  static set name1(value: string) { // 类的静态访问器中的 this 指向类本身
    this._name = value;
  }
  @log
  get name() {
    return this._name;
  }
  set name(value: string) {
    this._name = value;
  }
}
const user = new User("Alice");
user.name
user.name = 'zs'
